package com.example.demo1122.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo1122.domain.ResponseResult;
import com.example.demo1122.entity.Conversation;
import com.example.demo1122.entity.Question;
import com.example.demo1122.entity.Teacherforclass;
import com.example.demo1122.mapper.QuestionMapper;
import com.example.demo1122.mapper.TeacherforclassMapper;
import com.example.demo1122.service.ITeacherforclassService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2023-12-21
 */
@Service
public class TeacherforclassServiceImpl extends ServiceImpl<TeacherforclassMapper, Teacherforclass> implements ITeacherforclassService {

    @Resource
    private TeacherforclassMapper teacherforclassMapper;
    //查找课堂是否存在

    @Override
    public boolean existsTeacherId(String teacherID) {
        return teacherforclassMapper.countByTeacherId(teacherID) > 0;
    }

    @Override
    public boolean existsTeacherIdandClassID(String teacherID,Integer classID) {
        return teacherforclassMapper.countByClassIdAndTeacherId(classID, teacherID) > 0;
    }

    @Override
    public ResponseResult getStudentConversationList(String studentID, Integer classID, Integer chapterID) {
        try {
            List<Conversation> studentConversationList = teacherforclassMapper.getStudentConversationList(studentID, classID, chapterID);
            return new ResponseResult<>(1,"success",studentConversationList);
        } catch (Exception e) {
            return new ResponseResult<>(0, "error", e);
        }
    }

}
